package cn;

import java.util.Arrays;
import java.util.Scanner;

public class SameCount {
	int input() {
		int count = 0;// 统计相同的个数
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入第一个数组长度：");
		int len1 = sc.nextInt();
		System.out.println("请输入第二个数组长度：");
		int len2 = sc.nextInt();
		int[] arr1 = new int[len1];
		int[] arr2 = new int[len2];
		System.out.println("请输入第一个数组：");
		for (int i = 0; i < arr1.length; i++) {
			arr1[i] = sc.nextInt();
		}
		System.out.println("请输入第二个数组：");
		for (int i = 0; i < arr2.length; i++) {
			arr2[i] = sc.nextInt();
		}
		System.out.println("请输出这两个数组：");
		System.out.println(Arrays.toString(arr1));
		System.out.println(Arrays.toString(arr2));

		for (int i = 0; i < arr1.length; i++) {
			for (int j = 0; j < arr2.length; j++) {
				if (arr1[i] == arr2[j])
					count++;
			}
		}
		System.out.println("输出相同的个数：" + count);
		return count;
	}

	public static void main(String[] args) {
		SameCount s = new SameCount();
		s.input();
	}
}